home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1997 September / Macworld (1997-09).dmg / Shareware World / Utilities / Text Processing / AlphaLite.6.52 / Tcl / SystemCode / menus.tcl < prev    next >
Text File  |  1997-03-27  |  10KB  |  561 lines

  1. # My menus.        
  2.  
  3. if !$alphaLite {
  4.     menu -n File -p fileMenuProc {
  5.         "/Nnew"
  6.         "/Oopen…"
  7.         {menu -n recent {}}
  8.         "<S/Wclose"
  9.         "<S<O<U/WcloseFloat"
  10.         "<S<I<O/WcloseAll"
  11.         "(-"
  12.         "<S/Ssave"
  13.         "<S<I<O/SsaveAll"
  14.         "<SsaveACopyAs…"
  15.         "<SsaveAs…"
  16.         "<E<SrevertToBackup"
  17.         "<Srevert"
  18.         "(-"
  19.         "<S/Y<Oshell"
  20.         "<S/Y<U<Ocalculator"
  21.         "<S/Y<B<OtoolserverShell"
  22.         "(-"
  23.         "pageSetup…"
  24.         {menu -n print {}}
  25.         "(-"
  26.         "/Qquit"
  27.     }
  28.  
  29.     menu -n Edit {
  30.         "/Zundo"
  31.         "/Z<I<Oredo"
  32.         "/Lload"
  33.         "(-"
  34.         "/X<Scut"
  35.         "/X<S<I<Ocut&Append"
  36.         "/C<Scopy"
  37.         "/C<S<I<Ocopy&Append"
  38.         "/V<Spaste"
  39.         "/V<S<I<OpastePop"
  40.         "/A<SselectAll"
  41.         "/A<S<I<OselectParagraph"
  42.         "clear"
  43.         "(-"
  44.         {menu -n emacs {}}
  45.         "/`<Stwiddle"
  46.         "/`<S<I<OtwiddleWords"
  47.         "(-"
  48.         {/[<SshiftLeft}
  49.         {/[<S<I<OshiftLeftSpace}
  50.         {/]<SshiftRight}
  51.         {/]<S<I<OshiftRightSpace}
  52.         "/Bbalance"
  53.     }
  54.  
  55.     menu    -n Text {
  56.             "/I<SfillParagraph"
  57.             "/I<S<O<IwrapParagraph"
  58.             "/I<S<O<I<UsentenceParagraph"
  59.             "/U<S<OfillRegion"
  60.             "/U<S<I<OwrapRegion"
  61.             "/U<S<O<I<UsentenceRegion"
  62.             "<E<SparagraphToLine"
  63.             "<SlineToParagraph"
  64.             "(-"
  65.             "<SreverseSort"
  66.             "<SsortLines"
  67.             "/L<I<OspellcheckWindow"
  68.             "(-"
  69.             "zapInvisibles"
  70.             "<SspacesToTabs"
  71.             "<StabsToSpaces"
  72.             "<S<EindentRegion"
  73.             "<SindentLine"
  74.             "<E<SdowncaseRegion"
  75.             "<SupcaseRegion"
  76.             "(-"
  77.             {menu -n Strings {
  78.                 "<SremovePrefix"
  79.                 "<SinsertPrefix"
  80.                 "<S<EremoveSuffix"
  81.                 "<SinsertSuffix"
  82.                 "setPrefix"
  83.                 "setSuffix"
  84.                 }}
  85.             "/D<ScommentLine"
  86.             "/D<S<I<OuncommentLine"
  87.             "<SuncommentBox"
  88.             "<ScommentBox"
  89.             "<S<EuncommentParagraph"
  90.             "<ScommentParagraph"
  91.             "(-"
  92.             "/K<I<OgotoFunc"
  93.             "/=markHilite"
  94.             {menu -n namedMarks -p namedMarkProc {
  95.                 "/K<Oset…"
  96.                 "goto…"
  97.                 "remove…"
  98.                 "(-"
  99.                 "sort"
  100.                 "sortByPosition"}}
  101.             {menu -n unnamedMarks -p unnamedMarkproc {
  102.                 "set…"
  103.                 "exchangePointAndMark"}}
  104.     }
  105.  
  106.     menu -n "Utils" {
  107.             {menu -n fileUtils {
  108.                 "insertPathName…"
  109.                 "insertFile…"
  110.                 "fileRemove…"
  111.                 "fileInfo…"
  112.                 "wordCount"
  113.                 "textToAlpha"}}
  114.             {menu -m -n compare -p compareProc {
  115.                 "Windows"
  116.                 "Files…"
  117.                 "Directories…"}}
  118.             {menu -n asciiEtc {
  119.                 "quoteChar"
  120.                 "(-"
  121.                 "keyCode"
  122.                 "keyAscii"
  123.                 "getAscii"
  124.                 "insertAscii"}}
  125.             {menu -n KbdMacros {
  126.                 "/qstartKeyboardMacro"
  127.                 "/rendKeyboardMacro"
  128.                 "/sexecuteKeyboardMacro"
  129.                 "(-"
  130.                 "nameLastMacro"
  131.                 "deleteNamedMacro"
  132.                 "dumpNamedMacro"
  133.                 "(-"
  134.                 "menu -n macros {}"}}
  135.             "(-"
  136.             "sendUrl"
  137.             {menu -m -n switchTo -p switchProc {}}
  138.             "(-"
  139.             "/M<I<OmatchingLines"
  140.             "gotoMatch"
  141.             "nextMatch"
  142.             "(-"
  143.             "/jcmdDoubleClick"
  144.     }
  145.     menu    -n Config {
  146.         {menu -n "Current Mode" -p modeOptions {
  147.             "menus…"
  148.             "flags…"
  149.             "editPrefs"
  150.             "loadPrefs…"
  151.             "describeMode"
  152.             "(-"
  153.             "/m<Uchange…"
  154.         }}
  155.         {menu -n Global -p globalOptions {
  156.             "menus…"
  157.             "flags…"
  158.             "editPrefs"
  159.             "listBindings"
  160.             "listFunctions"}}
  161.         "suffixMappings…"
  162.         "/kdescribeBinding"
  163.         "viewSavedSetting…"
  164.         "removeSavedSetting…"
  165.         "(-"
  166.         {menu -n appPaths {}}
  167.         "helperApps…"
  168.         {menu -m -n install -p installProc {
  169.             "Electric Alias"
  170.             "(-"
  171.             "LaTeX 2e"
  172.             "LaTeX 2.09"}}
  173.         "deconstruct…"
  174.         "(-"
  175.         "/lsetFontsTabs…"
  176.         {menu -n redefineColors -p colorProc {
  177.             foreground
  178.             background
  179.             "(-"
  180.             blue
  181.             cyan
  182.             green
  183.             magenta
  184.             red
  185.             white
  186.             yellow
  187.             "(-"
  188.             color_9
  189.             color_10
  190.             color_11
  191.             color_12
  192.             color_13
  193.             color_14
  194.             color_15}}
  195.     }
  196.  
  197.     menu -n $winMenu -p menuWin {
  198.             "//<Szoom"
  199.             "//<S<I<OsinglePage"
  200.             "<S/;chooseAWindow"
  201.             "/I<Biconify"
  202.             {menu -n arrange -p winTileProc {
  203.                 "/Jvertically^1"
  204.                 "/J<O<Ihorizontally^2"
  205.                 "/J<B<OunequalVert^6"
  206.                 "/J<B<I<OunequalHor^5"
  207.                 "(-"
  208.                 {menu -n other {
  209.                     {bufferOtherWindow}
  210.                     {iconify}
  211.                     {nextWin}
  212.                     {nextWindow}
  213.                     {prevWindow}
  214.                     {shrinkFull}
  215.                     {shrinkHigh}
  216.                     {shrinkLeft}
  217.                     {shrinkLow}
  218.                     {shrinkRight}
  219.                     {singlePage}
  220.                     {swapWithNext}
  221.                     {zoom}
  222.                 }}}}
  223.             "(-"
  224.             "/msplitWindow"
  225.             "/otoggleScrollbar"
  226.             "(-"
  227.     }
  228. } else {
  229.     menu -n File -p fileMenuProc {
  230.         "/Nnew"
  231.         "/Oopen…"
  232.         {menu -n recent {}}
  233.         "<S/Wclose"
  234.         "<S<I<O/WcloseAll"
  235.         "(-"
  236.         "<S/Ssave"
  237.         "<S<I<O/SsaveAll"
  238.         "<SsaveAs…"
  239.         "<E<SrevertToBackup"
  240.         "<Srevert"
  241.         "(-"
  242.         "pageSetup…"
  243.         "/Pprint…"
  244.         "(-"
  245.         "/Qquit"
  246.     }
  247.  
  248.     menu -n Edit {
  249.         "/Zundo"
  250.         "/Z<I<Oredo"
  251.         {menu -n emacs {}}
  252.         "(-"
  253.         "/X<Scut"
  254.         "/X<S<I<Ocut&Append"
  255.         "/C<Scopy"
  256.         "/C<S<I<Ocopy&Append"
  257.         "/V<Spaste"
  258.         "/V<S<I<OpastePop"
  259.         "/A<SselectAll"
  260.         "/A<S<I<OselectParagraph"
  261.         "clear"
  262.         "(-"
  263.         "/=selectLast"
  264.         "/`<Stwiddle"
  265.         "/`<S<I<OtwiddleWords"
  266.     }
  267.  
  268.     menu -n Text {
  269.         "/I<SfillParagraph"
  270.         "/I<S<O<IwrapParagraph"
  271.         "/I<S<O<U<I<BsentenceParagraph"
  272.         "/U<S<OfillRegion"
  273.         "/U<S<I<OwrapRegion"
  274.         "/U<S<O<U<I<BsentenceRegion"
  275.         "<E<SupcaseRegion"
  276.         "<SdowncaseRegion"
  277.         "(-"
  278.         "<SreverseSort"
  279.         "<SsortLines"
  280.         "/L<I<OspellcheckWindow"
  281.         "zapInvisibles"
  282.         "<SspacesToTabs"
  283.         "<StabsToSpaces"
  284.         "(-"
  285.         "/K<I<OgotoFunc"
  286.         "(-"
  287.         "/D<ScommentLine"
  288.         "/D<S<I<OuncommentLine"
  289.         "<SuncommentBox"
  290.         "<ScommentBox"
  291.         "<S<EuncommentParagraph"
  292.         "<ScommentParagraph"
  293.         "(-"
  294.         "textToAlpha"
  295.     }
  296.  
  297.     menu    -n Config {
  298.         {menu -n "Current Mode" -p modeOptions {
  299.             "menus…"
  300.             "flags…"
  301.             "editPrefs"
  302.             "loadPrefs…"
  303.             "describeMode"
  304.             "(-"
  305.             "/m<Uchange…"
  306.         }}
  307.         {menu -n Global -p globalOptions {
  308.             "menus…"
  309.             "flags…"
  310.             "editPrefs"
  311.             "listBindings"
  312.             "listFunctions"}}
  313.         "suffixMappings…"
  314.         "helperApps…"
  315.         "(-"
  316.         "/kdescribeBinding"
  317.         "viewSavedSetting…"
  318.         "removeSavedSetting…"
  319.         "(-"
  320.         "/lsetFontsTabs…"
  321.     }
  322.  
  323.     menu -n $winMenu -p menuWin {
  324.             "//<Szoom"
  325.             "//<S<I<OsinglePage"
  326.             "<S/;chooseAWindow"
  327.             "/I<Biconify"
  328.             {menu -n arrange -p winTileProc {
  329.                 "/Jvertically^1"
  330.                 "/J<O<Ihorizontally^2"
  331.                 "/J<B<OunequalVert^6"
  332.                 "/J<B<I<OunequalHor^5"
  333.                 }}
  334.             "(-"
  335.             "/isetFontsTabs…"
  336.             "/msplitWindow"
  337.             "/otoggleScrollbar"
  338.             "(-"
  339.     }
  340. }
  341.  
  342.  
  343. proc fileMenuProc {menu item} {
  344.     if {$item == "open"} {
  345.         findFile
  346.     } elseif {$item == "close"} {
  347.         killWindow
  348.     } else {
  349.         $item
  350.     }
  351. }
  352.  
  353.  
  354.  
  355.  
  356.  
  357. menu -n Search {
  358.     "/F<Sfind…"
  359.     "/F<S<I<OsearchStart"
  360.     "/G<SfindAgain"
  361.     "/G<S<I<OfindAgainBackward"
  362.     "/MfindInNextFile"
  363.     "/E<SenterSearchString"
  364.     "/E<S<I<OenterReplaceString"
  365.     "(-"
  366.     "/S<BquickFind"
  367.     "/R<BreverseQuickFind"
  368.     "(-"
  369.     "/Rreplace"
  370.     "/Hreplace&FindAgain"
  371.     "<S/R<O<IreplaceAll"
  372.     "<S/R<O<I<BreplaceInFileset"
  373.     "(-"
  374.     "/,<BpushPosition"
  375.     "/.<BpopPosition"
  376.     "/G<IgotoLine"
  377. }
  378. proc pushPosition {} {pushMark}
  379. proc popPosition {} {popMark}
  380. #     {menu -n NamedClipboards -p namedClipMenuProc {"copy…" "cut…" "paste…"}}
  381. #     {menu -n registers { pointToRegister jumpToRegister }}
  382.  
  383. proc namedMarkProc {menu item} {
  384.     switch $item {
  385.         "markFile"            {markFile; message "File marked."}
  386.         "set"                 {setNamedMark}
  387.         "goto"                {gotoFileMark}
  388.         "remove"            {removeNamedMark}
  389.         "sort"                {sortMarksFile}
  390.         "sortByPosition"    {orderMarks}
  391.     }
  392. }
  393.  
  394. proc unnamedMarkproc {menu item} {
  395.     switch $item {
  396.         "set"                     {setMark}
  397.         "exchangePointAndMark"    {exchangePointAndMark}
  398.         "hilite"                {markHilite}
  399.     }
  400. }
  401.     
  402. proc installProc {menu item} {
  403.     switch $item {
  404.         "Electric Alias"     {loadElectricAlias}
  405.         "LaTeX 2.09"        {loadLaTeX}
  406.         "LaTeX 2e"            {loadLaTeX}
  407.     }
  408. }
  409.  
  410.  
  411.  
  412. proc compareProc {menu item} {
  413.     catch {compare$item} msg
  414.     message $msg
  415. }
  416.  
  417. proc namedClipMenuProc {menu item} {
  418.     switch $item {
  419.         "copy"         "copyNamedClipboard"
  420.         "cut"         "cutNamedClipboard"
  421.         "paste"     "pasteNamedClipboard"
  422.     }
  423. }
  424.  
  425.         
  426.  
  427.  
  428.  
  429. proc colorProc {menu item} {
  430.     global colorInds modifiedArrVars
  431.     if {[info exists colorInds($item)]} {
  432.         set color [eval [list colorTriple "New \"$item\":"] $colorInds($item)]
  433.     } else {
  434.         switch $item {
  435.             foreground    { set inds "0 0 0" }
  436.             background    { set inds "65535 65535 65535" }
  437.             blue        { set inds "0 0 65535" }
  438.             cyan        { set inds "61404 11464 34250" }
  439.             green        { set inds "1151 33551 8297" }
  440.             magenta        { set inds "44790 1591 51333" }
  441.             red            { set inds "65535 0 0" }
  442.             white        { set inds "65535 65535 65535" }
  443.             yellow        { set inds "61834 64156 12512" }
  444.             default        { set inds "65535 65535 65535" }
  445.         }
  446.         set color [eval [list colorTriple "New \"$item\":"] $inds]
  447.     }
  448.     eval setRGB $item $color
  449.  
  450.     set colorInds($item) $color
  451.     lappend modifiedArrVars colorInds
  452. }
  453.  
  454.  
  455.         
  456. #===============================================================================
  457. proc helpMenu {item} {
  458.     global HOME
  459.     if {$item == "Alpha Manual"} {
  460.         edit -r "$HOME:Help:Manual"
  461.     } else {
  462.         edit -r "$HOME:Help:$item"
  463.     }
  464. }
  465.  
  466. if {![catch {glob "$HOME:Help:*"} files]} {
  467.     set men { "Alpha Manual" "Alpha Commands" "Tcl Commands" "(-" "Quick Start" "Readme" "Changes" "(-" }
  468.     foreach f [lsort -ignore $files] {
  469.         set f [file tail $f]
  470.         if {[lsearch $men $f] < 0} {
  471.             lappend men $f
  472.         }
  473.     }
  474.     foreach f $men {
  475.         addHelpMenu $f
  476.     }
  477.     unset men
  478. }
  479.  
  480. #===============================================================================
  481.  
  482.  
  483. proc buildSwitches {} {
  484.     global switchApps
  485.     
  486.     menu -m -n switchTo -p switchProc {"<O<I/NNow…" "Add…" "Remove…" "(-"}
  487.  
  488.     if {[info exists switchApps] && [llength $switchApps]} {
  489.         foreach app $switchApps {
  490.             lappend names [file tail $app]
  491.         }
  492.         foreach name [lsort -ignore $names] {
  493.             addMenuItem -m -l "blah" switchTo $name
  494.         }
  495.     }
  496. }
  497.  
  498.  
  499. proc switchProc {menu name} {
  500.     global switchTo switchApps
  501.  
  502.     if {$name == "Add"} {
  503.         set fname [getfile "Pick an app:"]
  504.         lappend switchApps $fname
  505.         addDef switchApps $switchApps
  506.         buildSwitches
  507.     } elseif {$name == "Remove"} {
  508.         foreach app $switchApps {
  509.             lappend apps [file tail $app]
  510.         }
  511.         set name [listpick -p "Remove which app?" $apps]
  512.         if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
  513.             set switchApps [lreplace $switchApps $ind $ind]
  514.             addDef switchApps $switchApps
  515.             buildSwitches
  516.         }
  517.     } elseif {$name == "Now"} {
  518.         switchApp
  519.     } else {
  520.         if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
  521.             if {[catch {switchTo $name}]} {
  522.                 launch -f [lindex $switchApps $ind]
  523.             }
  524.         }
  525.     }
  526. }
  527.         
  528.  
  529. proc winTileProc {menu item} {
  530.     win$item
  531. }
  532.  
  533.  
  534.  
  535. #             "tiled^3"
  536. #             "overlay^4"
  537.  
  538. # We may be reloading, so add whatever windows we have
  539. if {[info exists winNameToNum]} {
  540.     set nms [array names winNameToNum]
  541.     foreach name $nms {
  542.         regexp {[^:]*$} $name item
  543.         set num $winNameToNum($name)
  544.         if {$num < 10}     {
  545.             addMenuItem -m $winMenu /$num$item
  546.         } else {
  547.             addMenuItem -m $winMenu $item
  548.         }
  549.     }
  550. }
  551.  
  552. insertMenu "File"
  553. insertMenu "Edit"
  554. insertMenu "Text"
  555. insertMenu "Search"
  556. catch {insertMenu "Utils"}
  557. #enableMenuItem NamedClipboards paste off
  558. insertMenu "Config"
  559. insertMenu $winMenu
  560.  
  561.